//学长的代码,值得借鉴!!
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<queue>
#include<stack> 
#include<set>
#include<sstream>
#include <utility>
#define lowbit(x) (x&(-x))
#define endl "\n"
using namespace std;
typedef long long ll;
const int N = 200010;
const ll mod = 1e9 + 7;
typedef long long LL;
const LL inf = (LL)4e18;

ll arr[N];

int main()
{
    cin.tie(); std::ios::sync_with_stdio(false);

    int t;
    cin >> t;
    while (t--)
    {
        int n, k;
        cin >> n >> k;
        for (int i = 1; i <= n; i++)
        {
            cin >> arr[i];
        }
        ll l; ll r;
        l = arr[1] - k;
        r = arr[1] + k;
        int add = 0;
        for (int i = 1; i <= n; i++)
        {
            if (arr[i] - k > l)
                l = arr[i] - k;
            if (arr[i] + k < r)
                r = arr[i] + k;
            if (l > r)
            {
                add++;
                l = arr[i] - k;
                r = arr[i] + k;
            }
        }
        cout << add << endl;
    }

    return 0;
}
//自己的代码,核心部分用学长的思想
/*
#include <iostream>
using namespace std;
typedef long long ll;
int a[200010];

int main()
{
    cin.tie();
    std::ios::sync_with_stdio(false);

    int t;
    cin >> t;
    while (t--)
    {
        int ans = 0; // ans是v变化的次数
        ll n, x;
        cin >> n >> x;
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i];
        }
        ll L = a[1] - x;
        ll R = a[1] + x;
        for (int i = 2; i <= n; i++)
        {
            ll l = a[i] - x;
            ll r = a[i] + x;
            if (l > L)
                L = l;
            if (r < R)
                R = r;
            if (R < L)
            {
                ans++;
                L = a[i] - x;
                R = a[i] + x;
            }
        }
        cout << ans << endl;
    }

    return 0;
}
这个模块自己写的,是对的!!!
最开始没有使用加速,在第3个题超时了
for (int i = 2; i <= n; i++)
    {
        ll l = a[i] - x;
        ll r = a[i] + x;
        if ((l <= r && r < L && L <= R) || (L <= R && R < l && l <= r)) // 没交集
        {
            ans++;
            L = l;
            R = r;
        }
        else
        {
            L = L > l ? L : l;
            R = R < r ? R : r;
        }
    }
*/